<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>回顾defineProperty方法</title>
  <!-- 引入vue -->
  <script src="../js/vue.js"></script>
</head>

<!-- 

 -->

<body>
  <div id="root">
  </div>

  <script type="text/javascript">
    // 阻止vue启动的时候产生生产提示
    Vue.config.productionTip = false;

    let number = 20

    let preson = {
      name: "张三",
      sex: "男",
    }

    console.log('执行了data函数', preson);


    // 代理person对象
    Object.defineProperty(preson, "age", {
      get() {
        console.log('执行了get函数');
        return number
      },
      set(value) {
        console.log('执行了set函数', value);
        number = value
      }
    })
  </script>
</body>

</html>